<template>
  <div class="reportFormPage" v-if="show">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">{{ this.form.baobmc }}</div>
        <div class="codeText">
          <tr v-for="(item, index) in form.baobbhList">{{ item }}</tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="220px" class="top-table">
          <tbody>
          <tr>
            <td height="25" align="center" width="15%">
              <span style="width: 90px; display: inline-block">工程名称</span>
            </td>
            <td width="35%" class="text-center">
              <span>{{ form.gongcmc }}</span>
            </td>
            <td align="center" width="15%">
              <span style="width: 90px; display: inline-block">工程部位/用途</span>
            </td>
            <td width="35%" class="text-center">
              <span>{{ form.gongcbwyt }}</span>
            </td>
          </tr>
          <tr>
            <td height="50" align="center">样品信息</td>
            <td class="specimen-border" colspan="3">
              <span>样品名称：</span>
              <span :class="{ 'placeholder': !form.yangpmc }">{{ form.yangpmc }}</span>
              <span>；样品编号：</span>
              <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
              <span>；样品数量：</span>
              <span :class="{ 'placeholder': !form.yangpsl }">{{ form.yangpsl }}</span>
              <span>；样品状态：</span>
              <span :class="{ 'placeholder': !form.yangpzt }">{{ form.yangpzt }}</span>
              <span>；来样时间：</span>
              <span :class="{ 'placeholder': !form.yangpsj }">{{ form.yangpsj }}</span>
            </td>
          </tr>
          <tr>
            <td height="25" align="center" width="15%">
              <span style="width:90px;display:inline-block">试验检测日期</span>
            </td>
            <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
            <td width="35%" class="text-center">
              <el-input v-model="form.shiyjcrq"/>
            </td>
            <td align="center" width="15%">
              <span style="width:90px;display:inline-block">试验条件</span>
            </td>
            <td v-if="isPdf" width="35%">
              温度：
              <span style="display: inline-block; width: 10%;">{{ form.shiytjwd }}</span>
              ℃；湿度：
              <span style="display: inline-block; width: 10%;">{{ form.shiytjsd }}</span>%RH
            </td>
            <td v-else width="35%">
              温度：
              <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100"
                        style="width: 15%"/>
              ℃；湿度：
              <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100"
                        style="width: 15%"/>
              %RH
            </td>
          </tr>
          <tr>
            <td height="50" align="center" width="15%">
              <span style="width: 90px; display: inline-block">检测依据</span>
            </td>
            <td width="35%">
              <span v-if="isPdf">{{ form.jiancyj }}</span>
              <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark"
                        @dblclick.native="showBsJiancyjView" readonly/>
            </td>
            <td align="center" width="15%">
              <span style="width: 90px; display: inline-block">判定依据</span>
            </td>
            <td width="35%">
              <span v-if="isPdf">{{ form.pandyj }}</span>
              <el-input v-else type="textarea" v-model="form.pandyj" :rows="2"
                        @dblclick.native="showBsJudgeBaseView"
                        @focus="handleFocus('pandyj')" class="mark"/>
            </td>
          </tr>
          <tr class="bottom-border">
            <td height="50" align="center">
              <div>主要仪器设备</div>
              <div>名称及编号</div>
            </td>
            <td colspan="3">
              <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh"
                        class="height100 width100 mark"
                        @dblclick.native="showBsInstrumentView" readonly></el-input>
            </td>
          </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="580px" class="middle-table">
          <tbody>
          <tr>
            <td colspan="10">密度试验</td>
          </tr>
          <tr>
            <td colspan="2">样品缩分方法</td>
            <td colspan="8">
              <el-select clearable v-model="form.yangpsfff1" class="hide-icon width100 height100" placeholder>
                  <el-option label="分料器法" value="分料器法"></el-option>
                  <el-option label="分铲法" value="分铲法"></el-option>
                  <el-option label="四分法" value="四分法"></el-option>
                </el-select>
              <!-- <el-input  v-model="form.yangpsfff1"/> -->
            </td>
          </tr>
          <tr>
            <td colspan="2">浸没液体名称</td>
            <td colspan="1"><el-input  v-model="form.jinmytmc"/></td>
            <td colspan="2">恒温温度（℃）</td>
            <td colspan="1"><el-input  v-model="form.hengwwd"/></td>
            <td colspan="2">浸泡时间</td>
            <td colspan="2"><el-input  v-model="form.jinpsj"/></td>
          </tr>
          <tr>
            <td width="10%">试验次数</td>
            <td width="10%">匙、瓷皿、漏斗及试前瓷皿中试样的干燥质量m<sub>1</sub>（g）</td>
            <td width="10%">匙、瓷皿、漏斗及试后瓷皿中试样的干燥质量m<sub>2</sub>（g）</td>
            <td width="10%">加试样前比重瓶的第一次读数V<sub>1</sub>（mL）</td>
            <td width="10%">加试样后比重瓶的第二次读数V<sub>2</sub>（mL）</td>
            <td width="10%">试样表观密度测值(g/cm³)</td>
            <td width="10%">试样表观密度测定值 (g/cm³)</td>
            <td width="10%">浸没液体的温度(℃)</td>
            <td width="10%">水的密度(g/cm³)</td>
            <td width="10%">试样表观相对密度测定值</td>
          </tr>
          <tr height="40">
            <td width="10%">{{ form.midsycsItem1 }}</td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsygzzl1Item1"
                        @change="computeMd(1)"
                        @keydown.native="handleKeyDown($event, 0, 0)"
                        @paste.native="handlePaste($event, 0, 0)"
                        :ref="'0_0'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsygzzl2Item1"
                        @change="computeMd(1)"
                        @keydown.native="handleKeyDown($event, 0, 1)"
                        @paste.native="handlePaste($event, 0, 1)"
                        :ref="'0_1'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsycdsItem1"
                        @change="computeMd(1)"
                        @keydown.native="handleKeyDown($event, 0, 2)"
                        @paste.native="handlePaste($event, 0, 2)"
                        :ref="'0_2'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsyzdsItem1"
                        @change="computeMd(1)"
                        @keydown.native="handleKeyDown($event, 0, 3)"
                        @paste.native="handlePaste($event, 0, 3)"
                        :ref="'0_3'"/>
            </td>
            <td width="10%">{{ form.midsykfmdczItem1 }}</td>
            <td width="10%" rowspan="2">{{ form.midsykfmdczPjz }}</td>
            <td width="10%" rowspan="2">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsyswdItem1"
                        @dblclick.native="showWatermdDetailView"
                        @keydown.native="handleKeyDown($event, 0, 4)"
                        :ref="'0_4'"/>
            </td>
            <td width="10%" rowspan="2">{{ form.midsysmdItem1 }}</td>
            <td width="10%" rowspan="2">{{ form.midsyxdmdczItem1 }}</td>
          </tr>
          <tr height="40">
            <td width="10%">{{ form.midsycsItem2 }}</td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsygzzl1Item2"
                        @change="computeMd(2)"
                        @keydown.native="handleKeyDown($event, 1, 0)"
                        @paste.native="handlePaste($event, 1, 0)"
                        :ref="'1_0'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsygzzl2Item2"
                        @change="computeMd(2)"
                        @keydown.native="handleKeyDown($event, 1, 1)"
                        @paste.native="handlePaste($event, 1, 1)"
                        :ref="'1_1'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsycdsItem2"
                        @change="computeMd(2)"
                        @keydown.native="handleKeyDown($event, 1, 2)"
                        @paste.native="handlePaste($event, 1, 2)"
                        :ref="'1_2'"/>
            </td>
            <td width="10%">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.midsyzdsItem2"
                        @change="computeMd(2)"
                        @keydown.native="handleKeyDown($event, 1, 3)"
                        @paste.native="handlePaste($event, 1, 3)"
                        :ref="'1_3'"/>
            </td>
            <td width="10%">{{ form.midsykfmdczItem2 }}</td>
          </tr>
          <tr>
            <td colspan="10">含水率试验（烘干法）</td>
          </tr>
          <tr>
            <td colspan="2">样品缩分方法</td>
            <td colspan="8">
              <!-- <el-input  v-model="form.yangpsfff2"/> -->
              <el-select clearable v-model="form.yangpsfff2" class="hide-icon width100 height100" placeholder>
                  <el-option label="分料器法" value="分料器法"></el-option>
                  <el-option label="分铲法" value="分铲法"></el-option>
                  <el-option label="四分法" value="四分法"></el-option>
                </el-select>
            </td>
          </tr>
          <tr>
            <td colspan="2">烘干温度（℃）</td>
            <td colspan="3"><el-input  v-model="form.honggwd"/></td>
            <td colspan="2">烘干时间</td>
            <td colspan="3"><el-input  v-model="form.honggsj"/></td>
          </tr>
          <tr>
            <td width="10%">试验次数</td>
            <td width="20%" colspan="2">烘干前试样与容器总质量（g）</td>
            <td width="20%" colspan="2">烘干后试样与容器总质量（g）</td>
            <td width="10%" colspan="1">容器质量（g）</td>
            <td width="20%" colspan="2">含水率测值（%）</td>
            <td width="20%" colspan="2">含水率测定值（%）</td>
          </tr>
          <tr height="40">
            <td width="10%">{{ form.hanslsycsItem1 }}</td>
            <td width="20%" colspan="2">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.hanslsyhstzlItem1"
                        @change="computeHsl(1)"
                        @keydown.native="handleKeyDown($event, 2, 0)"
                        @paste.native="handlePasteTwo($event, 0, 0)"
                        :ref="'2_0'"/>
            </td>
            <td width="20%" colspan="2">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.hanslsyhgtzlItem1"
                        @change="computeHsl(1)"
                        @keydown.native="handleKeyDown($event, 2, 1)"
                        @paste.native="handlePasteTwo($event, 0, 1)"
                        :ref="'2_1'"/>
            </td>
            <td width="10%" colspan="1">
              <el-input type="text" v-model="form.hanslsyhzlItem1" class="pointer mark"
                        @dblclick.native="showBaQjDetailView('1')" readonly/>
            </td>
            <td width="20%" colspan="2">{{ form.hanslsyhslczItem1 }}</td>
            <td width="20%" colspan="2" rowspan="2">{{ form.hanslsyhslczPjz }}</td>
          </tr>
          <tr height="40">
            <td width="10%">{{ form.hanslsycsItem2 }}</td>
            <td width="20%" colspan="2">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.hanslsyhstzlItem2"
                        @change="computeHsl(2)"
                        @keydown.native="handleKeyDown($event, 3, 0)"
                        @paste.native="handlePasteTwo($event, 1, 0)"
                        :ref="'3_0'"/>
            </td>
            <td width="20%" colspan="2">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.hanslsyhgtzlItem2"
                        @change="computeHsl(2)"
                        @keydown.native="handleKeyDown($event, 3, 1)"
                        @paste.native="handlePasteTwo($event, 1, 1)"
                        :ref="'3_1'"/>
            </td>
            <td width="10%" colspan="1">
              <el-input type="text" v-model="form.hanslsyhzlItem2" class="pointer mark"
                        @dblclick.native="showBaQjDetailView('2')" readonly/>
            </td>
            <td width="20%" colspan="2">{{ form.hanslsyhslczItem2 }}</td>
          </tr>
          <tr>
            <td colspan="10">亲水系数试验</td>
          </tr>
          <tr>
            <td colspan="2">样品缩分方法</td>
            <td colspan="8">
              
              <!-- <el-input  v-model="form.yangpsfff3"/> -->
            
              <el-select clearable v-model="form.yangpsfff3" class="hide-icon width100 height100" placeholder>
                  <el-option label="分料器法" value="分料器法"></el-option>
                  <el-option label="分铲法" value="分铲法"></el-option>
                  <el-option label="四分法" value="四分法"></el-option>
                </el-select>
            </td>
          </tr>
          <tr>
            <td  rowspan="2" >试验次数</td>
            <td  rowspan="1" colspan="3">水中沉淀物体积（mL）</td>
            <td  rowspan="1" colspan="3">煤油中沉淀物体积V<sub>H</sub>（mL）</td>
            <td  rowspan="2" >水中沉淀物体积平均值V<sub>B</sub>（mL）</td>
            <td  rowspan="2" >煤油中沉淀物体积平均值V<sub>H</sub>（mL）</td>
            <td  rowspan="2" >亲水系数测定值</td>
          </tr>
          <tr>
            <td  colspan="1">第1次</td>
            <td  colspan="1">第2次</td>
            <td  colspan="1">第3次</td>
            <td  colspan="1">第1次</td>
            <td  colspan="1">第2次</td>
            <td  colspan="1">第3次</td>
          </tr>
          <tr height="40">
            <td >{{ form.qinsxssycsItem1 }}</td>
            <td ><el-input  v-model="form.shuiztj11"/></td>
            <td ><el-input  v-model="form.shuiztj12"/></td>
            <td ><el-input  v-model="form.shuiztj13"/></td>
            <td ><el-input  v-model="form.meiytj11"/></td>
            <td ><el-input  v-model="form.meiytj12"/></td>
            <td ><el-input  v-model="form.meiytj13"/></td>
            <td rowspan="2"><el-input  v-model="form.shuizcdwtjpjz"/></td>
            <td rowspan="2"><el-input  v-model="form.meiyzcdwtjpjz"/></td>
            <td  rowspan="2">{{ form.qinsxssysyqsxtczPjz }}</td>
          </tr>
          <tr height="40">
            <td >{{ form.qinsxssycsItem2 }}</td>
            <td ><el-input  v-model="form.shuiztj21"/></td>
            <td ><el-input  v-model="form.shuiztj22"/></td>
            <td ><el-input  v-model="form.shuiztj23"/></td>
            <td ><el-input  v-model="form.meiytj21"/></td>
            <td ><el-input  v-model="form.meiytj22"/></td>
            <td ><el-input  v-model="form.meiytj23"/></td>
          </tr>
          <tr>
            <td colspan="10">加热安定性试验</td>
          </tr>
          <tr>
            <td colspan="2">样品缩分方法</td>
            <td colspan="8">
              <!-- <el-input  v-model="form.yangpsfff4"/> -->
              <el-select clearable v-model="form.yangpsfff4" class="hide-icon width100 height100" placeholder>
                  <el-option label="分料器法" value="分料器法"></el-option>
                  <el-option label="分铲法" value="分铲法"></el-option>
                  <el-option label="四分法" value="四分法"></el-option>
                </el-select>
            </td>
          </tr>
          <tr>
            <td width="10%">试验次数</td>
            <td width="40%" colspan="4">试样质量（g）</td>
            <td width="50%" colspan="5">试样加热到200℃后颜色变化情况</td>
          </tr>
          <tr height="50">
            <td width="10%">{{ form.jiaradxsycsItem1 }}</td>
            <td width="40%" colspan="4">
              <el-input :type="isPdf ? 'string' : 'number'"
                        v-model="form.jiaradxsysyzlItem1"
                        @keydown.native="handleKeyDown($event, 6, 0)"
                        @paste.native="handlePasteTwo($event, 4, 0)"
                        :ref="'6_0'"/>
            </td>
            <td width="50%" colspan="5">
              <el-input v-model="form.jiaradxsyysbhqkItem1"
                        @change="jradxzlChange"
                        @keydown.native="handleKeyDown($event, 6, 1)"
                        @paste.native="handlePasteTwo($event, 4, 1)"
                        :ref="'6_1'"/>
            </td>
          </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="100px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm"
                        @focus="handleFocus('fujsm')"/>
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
        <tr>
          <td width="10%" align="right">检测：</td>
          <td width="15%" align="left">
            <!-- {{this.form.jiancr}} -->
          </td>
          <td width="10%" align="right">记录：</td>
          <td width="15%" align="left">
            <!-- {{this.form.jilr}} -->
          </td>
          <td width="10%" align="right">复核：</td>
          <td align="left" width="15%">
            <!-- {{this.form.fuhr}} -->
          </td>
          <td width="10%">日期：</td>
          <td align="left" width="15%">
            <div style="display: inline-block; margin-right: 30px;">年</div>
            <div style="display: inline-block; margin-right: 30px;">月</div>
            <div style="display: inline-block;">日</div>
          </td>
        </tr>
        </tbody>
      </table>
    </div>

    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    <watermd-detail-view ref="watermdDetailViewRef" @select="selectWatermd"></watermd-detail-view>
    <ba-qj-detail-view ref="baQjDetailViewRef" :excelId="excelId" :shiyjcrq="form.shiyjcrq"
                       @select="selectBaQjDetail"></ba-qj-detail-view>
  </div>
</template>

<script>
import decimal from "@/utils/big-decimal";
import {handleFocus, emptyConvert, handleKeyDown, handlePaste} from "@/views/reportForms/utils";
import Bus from "@/utils/bus";

import {getKfmdhslsyjlbBsInfo} from "@/api/report_jl/kf";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import WatermdDetailView from "@/views/sycs/dataBase/WatermdDetailView";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";

export default {
  name: "kfmdhslsyjlbTable",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView,
    WatermdDetailView,
    BaQjDetailView,
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      form: {
        detailList: [],
        baobbhList: []
      },
      backBgz: {},
      show: false,
      showQyxx: false
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = {...emptyConvert(this.form, newVal)};
    },
    backBgz: {
      deep: true,
      immediate: true,
      handler(newVal, oldVal) {
        this.backBgzFun();
      }
    }
  },
  created() {
    this.init();
  },
  methods: {
    // 根据报表id获取当前报表信息
    init() {
      this.show = false;
      // if (!this.excelId) {
      //     const {jiancdwmc, gongcmc} = this.$store.state.dept.deptInfo;
      //     this.form.jiancdwmc = jiancdwmc;
      //     this.form.gongcmc = gongcmc;
      //     this.form.fujsm = "附加声明：";
      //     return;
      // }
      getKfmdhslsyjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        this.setInitialValue();
        this.show = true;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    // 设置初始值
    setInitialValue() {
      if (this.form) {
        this.form.baobmc = this.form.baobmc || "填料密度、含水率、亲水系数、加热安定性试验检测记录表";
        this.form.baobbh = this.form.baobbh || "JGLQ02027,JGLQ02028,JGLQ02029,JGLQ02031";
        this.$set(this.form, "baobbhList", []);
        this.form.baobbhList = ["JGLQ02027", "JGLQ02028", "JGLQ02029", "JGLQ02031"];
        this.form.midsycsItem1 = "1";
        this.form.midsycsItem2 = "2";
        this.form.hanslsycsItem1 = "1";
        this.form.hanslsycsItem2 = "2";
        this.form.qinsxssycsItem1 = "1";
        this.form.qinsxssycsItem2 = "2";
        this.form.jiaradxsycsItem1 = "1";
      }
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setKfBgJiancyj", {jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds});
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setKfBgZhuyyqsbmcjbh", {zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds});
    },
    // 温度水密度选择
    showWatermdDetailView() {
      this.$refs.watermdDetailViewRef.init();
    },
    selectWatermd(info) {
      this.form.midsyswdItem1 = info.temp;
      this.form.midsysmdItem1 = info.density;
      this.computeXdmd();
    },
    // 显示盒号列表
    showBaQjDetailView(type) {
      this.collectHehId();
      this.$refs.baQjDetailViewRef.init(type, this.form.hehIdList);
    },
    // 盒号选择
    selectBaQjDetail(type, obj) {
      this.form["h1" + type] = obj.hh;
      this.form["heh1" + type + "Id"] = obj.detailId;
      this.form["hanslsyhzlItem" + type] = obj.quality;
      this.computeHsl(type);
    },
    // 汇总盒号id
    collectHehId() {
      const arr = ["11", "12"];
      let hehIdList = [];
      arr.forEach((item) => {
        if (this.form["heh" + item + "Id"]) {
          hehIdList.push(this.form["heh" + item + "Id"]);
        }
      });
      this.form.hehIdList = hehIdList;
    },
    // 返回报告引入值
    backBgzFun() {
      Bus.$emit("setCjlBgJiancjg", [
        {key: 64, value: this.form.midsykfmdczPjz}, // 密度
        {key: 65, value: this.form.midsyxdmdczItem1}, // 相对密度
        {key: 66, value: this.form.hanslsyhslczPjz}, // 含水率
        {key: 67, value: this.form.qinsxssysyqsxtczPjz}, // 亲水系数
      ]);
      let obj = {};
      if (this.form.jiaradxsyysbhqkItem1) {
        obj = {jiszb: '实测结论', jiancjg: this.form.jiaradxsyysbhqkItem1, jiegpd: '符合'}; // 加热安定性质量
      } else {
        obj = {jiszb: '-', jiancjg: '-', jiegpd: '-'}; // 加热安定性质量
      }
      Bus.$emit("setCjlBgOther", obj);
    },
    submitForm() {
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    // 试样对水的相对密度测定制
    computeXdmd() {
      if (this.form.midsykfmdczItem1 && this.form.midsykfmdczItem2 && this.form.midsysmdItem1) {
        const a = decimal.add(this.form.midsykfmdczItem1, this.form.midsykfmdczItem2);
        const b = decimal.divide(a, 2);
        if (this.form.midsysmdItem1 != 0) {
          const c = decimal.divide(b, this.form.midsysmdItem1, 3);
          this.form.midsyxdmdczItem1 = c;
        } else {
          this.form.midsyxdmdczItem1 = null;
        }
      } else {
        this.form.midsyxdmdczItem1 = null;
      }
      this.backBgzFun();
    },
    // 密度测值
    computeMd(item) {
      if (this.form["midsygzzl1Item" + item] && this.form["midsygzzl2Item" + item] && this.form["midsycdsItem" + item] && this.form["midsyzdsItem" + item]) {
        const a = decimal.subtract(this.form["midsygzzl1Item" + item], this.form["midsygzzl2Item" + item]);
        const b = decimal.subtract(this.form["midsyzdsItem" + item], this.form["midsycdsItem" + item]);
        if (b != 0) {
          const c = decimal.divide(a, b, 3);
          this.form["midsykfmdczItem" + item] = c;
        } else {
          this.form["midsykfmdczItem" + item] = null;
        }
      } else {
        this.form["midsykfmdczItem" + item] = null;
      }
      this.mdPjz();
      this.computeXdmd();
    },
    // 密度平均值
    mdPjz() {
      if (this.form.midsykfmdczItem1 && this.form.midsykfmdczItem2) {
        const a = decimal.add(this.form.midsykfmdczItem1, this.form.midsykfmdczItem2);
        const b = decimal.divide(a, 2, 3);
        this.form.midsykfmdczPjz = b;
      } else {
        this.form.midsykfmdczPjz = null;
      }
      this.backBgzFun();
    },
    // 含水率测值
    computeHsl(item) {
      if (this.form["hanslsyhstzlItem" + item] && this.form["hanslsyhgtzlItem" + item] && this.form["hanslsyhzlItem" + item]) {
        const a = decimal.subtract(this.form["hanslsyhstzlItem" + item], this.form["hanslsyhgtzlItem" + item]);
        const b = decimal.subtract(this.form["hanslsyhgtzlItem" + item], this.form["hanslsyhzlItem" + item]);
        if (b != 0) {
          const c = decimal.divide(a, b, 5);
          const d = decimal.multiply(c, 100, 1);
          this.form["hanslsyhslczItem" + item] = d;
        } else {
          this.form["hanslsyhslczItem" + item] = null;
        }
      } else {
        this.form["hanslsyhslczItem" + item] = null;
      }
      this.hslPjz();
    },
    // 含水率平均值
    hslPjz() {
      if (this.form.hanslsyhslczItem1 && this.form.hanslsyhslczItem2) {
        const a = decimal.add(this.form.hanslsyhslczItem1, this.form.hanslsyhslczItem2);
        const b = decimal.divide(a, 2, 1);
        this.form.hanslsyhslczPjz = b;
      } else {
        this.form.hanslsyhslczPjz = null;
      }
      this.backBgzFun();
    },
    // 亲水系数测值
    computeQsxs(item) {
      if (this.form["qinsxssyszcdwtjItem" + item] && this.form["qinsxssymyzcdwtjItem" + item] && this.form["qinsxssymyzcdwtjItem" + item] != 0) {
        const a = decimal.divide(this.form["qinsxssyszcdwtjItem" + item], this.form["qinsxssymyzcdwtjItem" + item]);
        this.form["qinsxssysyqsxtczItem" + item] = a;
      } else {
        this.form["qinsxssysyqsxtczItem" + item] = null;
      }
      this.qsxsPjz();
    },
    // 亲水系数平均值
    qsxsPjz() {
      if (this.form.qinsxssysyqsxtczItem1 && this.form.qinsxssysyqsxtczItem2) {
        const a = decimal.add(this.form.qinsxssysyqsxtczItem1, this.form.qinsxssysyqsxtczItem2);
        const b = decimal.divide(a, 2);
        this.form.qinsxssysyqsxtczPjz = b;
      } else {
        this.form.qinsxssysyqsxtczPjz = null;
      }
      this.backBgzFun();
    },
    // 加热安定性质量变化
    jradxzlChange() {
      this.backBgzFun();
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [4, 3, 1, 1, 1, 1, 1]; // 每一行最多有多少可聚焦输入框（从0开始）
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 粘贴赋值方法-密度试验
    handlePaste(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["midsygzzl1Item1", "midsygzzl2Item1", "midsycdsItem1", "midsyzdsItem1"],
        ["midsygzzl1Item2", "midsygzzl2Item2", "midsycdsItem2", "midsyzdsItem2"],
      ];
      const subscriptArr = [
        [0, 1, 2, 3],
        [0, 1, 2, 3],
      ];

      const methodsAllArr = [
        ["computeMd", "computeMd", "computeMd", "computeMd"],
        ["computeMd", "computeMd", "computeMd", "computeMd"],
      ];
      const parameterArr = [
        [1, 1, 1, 1],
        [2, 2, 2, 2],
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 粘贴赋值方法-含水率试验、亲水系数试验、亲水系数试验、加热安定性试验
    handlePasteTwo(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["hanslsyhstzlItem1", "hanslsyhgtzlItem1"],
        ["hanslsyhstzlItem2", "hanslsyhgtzlItem2"],

        ["qinsxssyszcdwtjItem1", "qinsxssymyzcdwtjItem1"],
        ["qinsxssyszcdwtjItem2", "qinsxssymyzcdwtjItem2"],

        ["jiaradxsysyzlItem1", "jiaradxsyysbhqkItem1"],
      ];
      const subscriptArr = [
        [0, 1],
        [0, 1],

        [0, 1],
        [0, 1],

        [0, 1],
      ];

      const methodsAllArr = [
        ["computeHsl", "computeHsl"],
        ["computeHsl", "computeHsl"],

        ["computeQsxs", "computeQsxs"],
        ["computeQsxs", "computeQsxs"],

        [null, "jradxzlChange"],
      ];
      const parameterArr = [
        [1, 1],
        [2, 2],

        [1, 1],
        [2, 2],

        [null, null],
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    }
  }
};
</script>

<style scoped lang="scss"></style>
